<template>
	<div class="yellow">
		<div class="header flex a-center jlr" style="z-index: 10;">
			<div class="back" @click="back"><i class="iconfont icon-arrow-left-copy"></i></div>
			<h2>售后详情</h2>
			<div class="back">&nbsp;</div>
		</div>

		<div class="abox">
			<div class="ferundInfo">
				<div class="tip" v-if="obj.returnOrderStatus==0">
					<h2>请等待商家处理</h2>
					<p>剩余时间{{obj.RemainTime}}</p>
				</div>
				<div class="tip" v-if="obj.returnOrderStatus==1">
					<h2>退款成功</h2>
					<p>退款将于{{obj.finishReturnTime | timer}}前退至您的微信账户</p>
				</div>
				<div class="tip" v-if="obj.returnOrderStatus==2">
					<h2>退款失败</h2>
					<p>失败原因:{{obj.rejectReason}}</p>
				</div>
				<div class="tip1">您已成功发起退款申请，请耐心等待商家处理</div>
				<div class="tiplist">
					<div class="item">商家同意或超时未处理，系统将退款给您</div>
					<div class="item">商家如果拒绝，您可以修改退款申请后再次发起，商家会重新处理</div>
					<div class="flex btngroupt" style="justify-content: flex-end;" v-if="obj.returnOrderStatus==0||obj.returnOrderStatus==2">
						<div class="btn1" @click="repeal" v-if="obj.returnOrderStatus==0">撤销申请</div>
						<div class="btn1" @click="anew" v-if="obj.returnOrderStatus==2">重新申请</div>
					</div>
				</div>
			</div>

			<div class="ferund" style="margin-top: 0.16rem;">
				<h1>退款商品</h1>
				<div style="margin-bottom: 0.16rem;">
					<div class="protitle flex" style="padding: 0 0.3rem;">
						<div class="proImage"><img :src="obj.frontPicUrl"></div>
						<div class="info flex col jlr">
							<div class="top">
								<h2>{{obj.productName}}</h2>
								<h4>颜色：{{obj.colorName}} <span>{{obj.speceName}}</span></h4>
							</div>
							<h3>￥{{obj.price}}</h3>
						</div>
					</div>
					<!--产品展示-->
				</div>
				<div class="ferundItem1">
					<p>退款原因：{{obj.reqReturnReason}}</p>
					<p>退款金额：￥{{obj.returnTotalAmt}}</p>
					<p>退款方式：原路返回</p>
					<p>退款时间：{{obj.reqReturnTime | timer}}</p>
				</div>

				<div class="blockbtn" style="margin-top: 0.4rem; background: #fb4f54; height: 0.8rem; line-height: 0.8rem;" @click="$kefu({type:'online'})">联系卖家</div>

			</div>

		</div>

	</div>
</template>
<script>
	export default {
		data() {
			return {
				obj: {},
				productInfoList: []
			}
		},
		activated() {
			this.init()
		},
		kf() {
			ysf('open');
		},
		created() {
			this.kfinit();
			ysf('onready', function() {})
		},
		methods: {
			kfinit() {
				(function(w, d, n, a, j) {
					w[n] = w[n] || function() {
						(w[n].a = w[n].a || []).push(arguments);
					};
					j = d.createElement('script');
					j.async = true;
					j.src = 'https://qiyukf.com/script/db27a46d9ddfb5a8b234c3a6d049acbc.js?hidden=1';
					d.body.appendChild(j);
				})(window, document, 'ysf');
			},
			repeal() {
				this.$ajax.cancelRefund({
					orderId: this.$route.query.id
				}).then(res => {
					if (res.code == 0) {
						this.$toast.success('取消申请成功')
					}
				})
			},
			anew() {
				this.$router.push('/ordershow?id=' + this.$route.query.id+'&productId='+this.$route.query.productId)
			},
			init() {
				this.$ajax.selectByOrderId({
					orderId: this.$route.query.id
				}).then(res => {
					console.log(res.data)
					this.obj = res.data
					//this.productInfoList = res.data.productInfoList
				})
			},
			back() {
				this.$router.go(-1)
			}
		},
		filters: {
			timer(v) {
				if (v) {
					var dateTime = new Date(v);
					var year = dateTime.getFullYear();
					var month = dateTime.getMonth() + 1;
					var day = dateTime.getDate();
					var hours = dateTime.getHours();
					var minutes = dateTime.getMinutes();
					var second = dateTime.getSeconds();
					month < 10 ? month = '0' + month : month;
					hours < 10 ? hours = '0' + hours : hours;
					minutes < 10 ? minutes = '0' + minutes : minutes;
					second < 10 ? second = '0' + second : second;
					//打印完整的系统日期;
					let dateStr = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes+':'+second;
					return dateStr;
				}else{
					return ''
				}
			}
		}
	}
</script>
